Function: projectile-search--rg-byte->char-column
projectile-search--rg-byte->char-column is a byte-compiled function
defined in projectile.el.
Signature
(projectile-search--rg-byte->char-column LINE BYTE)
Documentation
Return the 0-based character column for BYTE offset into LINE.
BYTE is a UTF-8 byte offset into the line text (as ripgrep reports submatch offsets); LINE is the already-decoded line string. The prefix is re-encoded to UTF-8 and its BYTE-long head decoded back, so multibyte characters before the match count as one column each, not one per byte.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-search--rg-byte->char-column (line byte)
"Return the 0-based character column for BYTE offset into LINE.
BYTE is a UTF-8 byte offset into the line text (as ripgrep reports
submatch offsets); LINE is the already-decoded line string. The prefix
is re-encoded to UTF-8 and its BYTE-long head decoded back, so multibyte
characters before the match count as one column each, not one per byte."
(if (or (null byte) (<= byte 0))
0
(let* ((bytes (encode-coding-string line 'utf-8))
(n (min byte (length bytes))))
(length (decode-coding-string (substring bytes 0 n) 'utf-8)))))